﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace QLab.UX.Forms
{
    public partial class ToolWindow : DockContent
    {
        private ToolStripMenuItem toolStripMenuItem;
        private DockPanel dockPanel;
        string name;

        public ToolWindow()
        {
            InitializeComponent();
        }

        public ToolWindow(string name, string text, ToolStripMenuItem toolStripMenuItem, DockPanel dockPanel)
        {
            InitializeComponent();
            this.name = name;
            this.Text = text;
            this.toolStripMenuItem = toolStripMenuItem;
            this.dockPanel = dockPanel;
            this.toolStripMenuItem.CheckedChanged += new EventHandler(toolStripMenuItem_CheckedChanged);
        }

        void toolStripMenuItem_CheckedChanged(object sender, EventArgs e)
        {
            if (toolStripMenuItem.Checked == false)
                this.Hide();
            else
                this.Show(dockPanel);
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);
            e.Cancel = true;
            toolStripMenuItem.Checked = false;
            this.Hide();
        }
    }
}
